package com.uinnova.springboot.initdata;

import com.uinnova.springboot.mongodb.User;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * sprin创建bean实例时会执行doCreateBean方法，创建完实例后会调用initializeBean方法进行初始化
 * 初始化的时候会检查有没有实现InitializingBean接口，如果实现了自动执行afterPropertiesSet方法进行初始化
 */
@Component
public class InitializingBeanTest implements InitializingBean {
    @Autowired
    User user;

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println(user);
    }
}
